package com.itheima.testjian;

public class BianLi {
    public static void main(String[] args) {
        //数组遍历
        int[] arr = {152, 11, 22, 33, 66};
//        printArray(arr);
        int max = getMax(arr);
        System.out.println(max);
    }

    //数组遍历
    public static void printArray(int[] arr) {
        System.out.print("[");
        for (int i = 0; i < arr.length; i++) {
            if (i == arr.length - 1) {
                System.out.println(arr[i] + "]");
            } else {
                System.out.print(arr[i] + ", ");
            }

        }
    }

    //获取数组最大值
    public static int getMax(int[] arr) {
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if(max < arr[i]){
                max = arr[i];
            }
        }
        return max;
    }
}
